{% extends "master.html" %} {% block title %}{% end %} {% block header%}{% end %} {% block sidebar_header %}{% end %}
{% block content_header_title%} {{current_menu_item["menu_title"]}} {% end %} {% block content_header_breadcrumb%}{% end %}
{% block content_body%}
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-body">
                <!-- form start -->
                <form role="form" id="options-general-form">
                    {% raw apply_filters("bo_options_general_form", "", screen_id, handler) %}
                    {% set opt_name = apply_filters("bo_options_general_name", screen_id, screen_id, handler) %}
                    <input type="hidden" id="option_name" name="option_name" value="{{opt_name}}" />
                </form>
            </div>
        </div>
    </div>
    <div class="col-md-12">
        <button type="button" class="btn btn-primary pull-right" id="options-general-btn">保存</button>
    </div>
</div>
{% end %} {% block footer%}
<script type="text/javascript">
    jQuery(function($) {
        $.post("{{api('bo_options_general_get')}}", {
            "option_name": $("#option_name").val()
        }, function(data) {
            $(".option").each(function() {
                var elem_name = $(this).attr("name");
                if (elem_name != undefined || elem_name != null || $.trim(elem_name) != "") {
                    var remote_v = data.data[elem_name.replace("opt_", "")];
                    var data_type = $(this).attr("type");
                    if (data_type == "radio") {
                        $('input[name="' + elem_name + '"]').each(function() {
                            $(this).prop("checked", false);
                            var v = $(this).val();
                            if ($.inArray(v, remote_v) != -1) {
                                $(this).prop("checked", true);
                            }
                        });
                    } else if (data_type == "checkbox") {
                        $(this).prop("checked", false);
                        var v = $(this).val();
                        if ($.inArray(v, remote_v) != -1) {
                            $(this).prop("checked", true);
                        }
                    } else {
                        $(this).val(remote_v[0]);
                    }
                }
            });
        }, "json");
        $("#options-general-btn").click(function() {
            var params = $("#options-general-form").serialize();
            $.post("{{api('bo_options_general_save')}}", params, function(rsp) {
                if(rsp.success){
                    bo_alert_success("设置", "保存成功");
                }else{
                    bo_alert_success("设置", "保存失败");
                }
            }, "json");
        });
    });
</script>
{% end %}